.SUFFIXES:.cpp .o

PP=g++
CC=gcc

INCLUDES=-Iinclude

SRCSpp=src/main_.cpp\
		src/stb.cpp \
		src/camera.cpp \
		src/utils.cpp \
		src/shader.cpp \
		src/mesh.cpp \
		src/model.cpp \
		src/loadobj.cpp
SRCScc=src/glad.c
OBJS=$(SRCSpp:.cpp=.o) $(SRCScc:.c=.o)
EXE=main

#########################
# 判断不同系统的编译环境 #
#########################
ifeq ($(OS),Windows_NT) 
	detected_OS := Windows
else
	detected_OS := $(shell uname -o 2>/dev/null || echo Unknown)
endif
ifeq ($(detected_OS),Windows)
	LIBS := -lglfw3dll -lopengl32 -lglu32 -lgdi32  -lassimp
	# assimp静态库太大,链接时间太长,所以改为链接本地动态库
	LINKS=-Llib -L.
endif
ifeq ($(detected_OS),GNU/Linux)
	LIBS := -lglfw3 -lX11 -ldl -lpthread -lassimp -lz
	LINKS=-Llib -Llib/assimp
endif
ifeq ($(detected_OS),Msys)
	LIBS := -lglfw3 -lopengl32 -lglu32 -lgdi32 
endif

start:$(OBJS)
	$(PP) $(LINKS) -o $(EXE) $(OBJS) $(LIBS)
	@make clean
	@echo "Compelete!!"
%.o:%.cpp
	$(PP) -o $@ -c $< $(INCLUDES)
%.o:%.c
	$(CC) -o $@ -c $< $(INCLUDES)
clean:
	rm -f $(OBJS)
test:
	@echo "detected_OS is " $(detected_OS)
	@echo "LIBS is " $(OS)
	@echo "LIBS is " $(LIBS)